package cn.majingjing.demo.aop.services;

import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Service;

import java.util.Date;

/**
 * @author JingjingMa
 * @date 2019/11/4 13:59
 */
@Service
public class ScheduleService {

    @Scheduled(cron = "0/5 * * * * ? ")
    public void task1() {
        System.out.println("task1 在指定时间 " + new Date() + "执行");
    }

    @Scheduled(cron = "0/6 * * * * ? ")
    public void task2() {
        System.out.println("task2 在指定时间 " + new Date() + "执行");
    }

    @Scheduled(cron = "0/7 * * * * ? ")
    public void task3() {
        System.out.println("task3 在指定时间 " + new Date() + "执行");
        try {
            Thread.sleep(5000L);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

}
